select = EMS_Do_Request( cmd.k 'header found' || cr || 'Original FileName:' name || cr || cr || 'A file with the same name exists in the' temp_dir 'directory.' || cr || 'Should I rename it to "' || name || '.EMS" ?', 'Yes|No' )
if select = 'Yes' then do
name = name'.EMS'
names.num = name
end
else do
select = EMS_Do_Request( 'Should I delete the existing file ?', 'Yes|No' )
if select = 'No' then do
call EMS_Do_Request( 'Extracting' cmd.k 'files has been stopped.' )
call QuitScript
end
address command delete_name name
end
end
if open( 'out', temp_file, 'W' ) ~= 1 then do
call EMS_Do_Request( 'Cannot open "' || temp_file || '" for output.' )
call QuitScript
end
call writeln( 'out', cmd.k.bgn name )
do forever
match = match + 1
line = lines.match
call writeln( 'out', line )
if left( line, length( cmd.k.end ) ) = cmd.k.end then leave
end
call close( 'out' )
address command cmd.k temp_file
address command delete_name temp_file
end
end
QuitScript:
call pragma( 'D', old_dir )
if names.0 > 0 then do
string = 'Check the' temp_dir 'directory for the file(s):'
do i = 1 to names.0
string = string || cr || ' ' || names.i
end
call EMS_Do_Request( string )
end
call EMS_FreeScriptData()
exit 0
Usage:
say 'Usage: ExtractFile.ems <area name> <msg num>'
call EMS_FreeScriptData()
exit 0
error:
syntax:
error_text = EMS_LastError()
if error_text = '' then error_text = rc ErrorText( rc )